<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>login</title>
    <link rel="stylesheet" href="css/login.css">
    <script src="../jquery-3.4.1.js"></script>
    <script src="../Cookie.js"></script>
</head>

<body>
    <div class="wrap login_wrap">
        <a class="bg_link" id="2014_login_background_a" target="_blank">&nbsp;</a>
        <div class="tab_box clearfix">
            <div data-ywpoint="null_null_null_null_I0200_0" class="item cur" id="commonLoginTab">
                <a href="javascript:switchLoginTab(1);">普通登录</a>
            </div>

        </div>
        <div class="tab_con" id="commonLogin">
            <h2 data-ywpoint="null_null_null_null_I0202_0" class="lg_title"><span class="fr">还不是1药网会员？<a
                        href="/sso/register.action" class="blue_link">免费注册</a></span>Hi，欢迎登录！</h2>
            <form autocomplete="off">
                <!--<div class="reg_form reg_form_step2"  id="reg_form_div1">-->
                <div class="reg_row">
                    <!-- 用户名 -->
                    <input type="text" name="ecuserCustomer.id" id="userName" autocomplete="off" placeholder="手机号"
                        class="form-control u_name" tabindex="1">
                    <i id="pas_empty" class="i_empty" style="display:none;">不能为空</i>
                    <span id="accountDesc" class="error"></span>
                </div>
                <div class="reg_row">
                    <!-- 密码 -->
                    <input type="password" id="userPass" name="ecuserCustomer.password" autocomplete="off"
                        placeholder="登录密码" class="form-control u_ps" tabindex="2">
                    <span class="fr"><a href="/sso/lost.action" tabindex="-1" target="_blank"
                            class="gray">忘记密码？</a></span>
                    <span id="pwd_desc" class="error"></span>
                </div>
                <div id="vcd_div" class="reg_row verify_box">
                    <input type="text" maxlength="4" id="vcd" tabindex="3" name="validCode" placeholder="验证码"
                        class="form-control u_verify">
                    <i id="vcd_tatus"></i>
                    <img id="loginVcode" class="code verifyimg"
                        onclick="this.src='/sso/getSecurityCode.action?t='+(new Date()).getTime()" alt="验证码"
                        src="/sso/getSecurityCode.action?t=1577936994170">
                    <a class="verifylink" id="changecode" tabindex="-1" href="javascript:void(0);">换一张</a>
                    <span id="vcd_desc" class="error"></span>
                </div>
                <div class="">
                    <!-- 1药网协议-->
                    <label class="checkbox"><input type="checkbox" value="1" name="rememberPwd" id="rememberPwd"
                            tabindex="-1">
                        <span class="two_week">两周内免登录</span>
                    </label>
                    <button data-ywpoint="null_null_null_null_I0203_0" type="button" id="btnSubmit"
                        class="btn btn-primary">登录</button><br>
                    <span id="login_desc" class="error"></span>
                </div>
            </form>
        </div>
    </div>
</body>
<script>
    $(() => {
        //点击登录
        // $("#rememberPwd").click(function () {
        //         console.log(1111);
        //         console.log($("#rememberPwd"));
        //         let name = $('#userName').val();
        //         let psw = $('#userPass').val();
        //         if ($(this).is(':checked')) {
        //             console.log(111);
        //             Cookie.setItem("uesrname", name, 14);
        //             Cookie.setItem("password", psw, 14);
        //         } else {
        //             Cookie.removeItem("uesrname", null, -1);
        //             Cookie.removeItem("password", null, -1);
        //         }
        //     })
        $('#btnSubmit').click(function () {
            let name = $('#userName').val();
            let psw = $('#userPass').val();
            if (name && psw) {
                $.ajax({
                    type: "post",
                    url: "../server/login.php",
                    data: {
                        name: name,
                        psw: psw
                    },
                    success: function (str) {
                        console.log(str);
                        Cookie.setItem("uesrname", name, "");
                        Cookie.setItem("password", psw, "");
                    }
                });

            } else {
                $("#pas_empty").css("display", "block");
                alert('请输入用户名和密码')
            }
            
        })

    })
</script>

</html>